﻿using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Web.Security;

namespace Coticula.Web.Models
{
    public class Results
    {
        public Results()
        {
            VerdictId = 1;
            Solution = new Solutions();
        }

        public Results(Results results, MembershipUser user)
        {
            Solution = results.Solution;
            Id = results.Id;
            VerdictId = results.VerdictId;
            Verdict = results.Verdict;
            User = user;
            Score = results.Score;
            CompiledDetailId = results.CompiledDetailId;
            CompiledDetail = results.CompiledDetail;
            TestsResults = results.TestsResults;
        }

        [NotMapped]
        public MembershipUser User { get; set; }

        private int _id;
        public int Id
        {
            get
            {
                return _id;
            }
            set
            {
                _id = value;
                Solution.Id = Id;
            }
        }

        public int VerdictId { get; set; }
        public Verdicts Verdict { get; set; }

        [Required]
        public Solutions Solution { get; set; }

        public virtual ICollection<TestsResults> TestsResults { get; set; }

        public int? CompiledDetailId { get; set; }
        public virtual CompiledDetails CompiledDetail { get; set; }

        public int Score { get; set; }
    }
}